﻿<UserControl
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
	xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
	xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
	xmlns:cmd="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.SL4"
	xmlns:local="clr-namespace:Microsoft.Windows.Controls;assembly=Microsoft.Windows.Controls.WatermarkedTextBox"
	mc:Ignorable="d"
	x:Class="Microsoft.OpenTurf.Silverlight.SearchView">
	
	<UserControl.DataContext>
		<Binding Source="{StaticResource Locator}" Path="Search" Mode="OneWay" />
	</UserControl.DataContext>

	<Grid x:Name="LayoutRoot">
		<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" Width="218" Height="206" VerticalAlignment="Top">
			<local:WatermarkedTextBox Text="{Binding UserInput, Mode=TwoWay}" Watermark="{Binding TextBoxWaterMarkText, Mode=TwoWay}" TextWrapping="NoWrap" VerticalAlignment="Top" VerticalScrollBarVisibility="Disabled" Margin="0" Width="150"/>
			<Button Height="26" VerticalAlignment="Top" Width="40" Content="Go">
				<i:Interaction.Triggers>
					<i:EventTrigger EventName="Click">
						<cmd:EventToCommand x:Name="PerformSearchAction" Command="{Binding PerformAction}" PassEventArgsToCommand="True" />
					</i:EventTrigger>
				</i:Interaction.Triggers>
			</Button>
			<Button ClickMode="Press" Style="{StaticResource ShowComponentsButton}" Content="V">
				<i:Interaction.Triggers>
					<i:EventTrigger EventName="Click">
						<cmd:EventToCommand x:Name="ShowSearchComponents" Command="{Binding OpenComponentSelector}" PassEventArgsToCommand="True"/>
					</i:EventTrigger>
				</i:Interaction.Triggers>
			</Button>
		</StackPanel>
		<ListBox HorizontalAlignment="Left" 
				 VerticalAlignment="Top" 
				 Width="201" Margin="9,27,0,0" 
				 Visibility="{Binding ComponentSelectorVisibility}" 
				 ItemsSource="{Binding SearchComponents}" 
				 BorderThickness="2"
				 MaxHeight="118">
			<ListBox.ItemTemplate>
				<DataTemplate>
					<StackPanel>
						<Image Source="{Binding Icon}" />
						<TextBlock Text="{Binding DisplayText}" />
					</StackPanel>
				</DataTemplate>
			</ListBox.ItemTemplate>
			<i:Interaction.Triggers>
				<i:EventTrigger EventName="SelectionChanged">
					<cmd:EventToCommand Command="{Binding SelectComponent}" PassEventArgsToCommand="True"/>
				</i:EventTrigger>
			</i:Interaction.Triggers>
		</ListBox>
	</Grid>
</UserControl>